//------------------------------------------------------------------------------
// Copyright (c) 2008 www.dnaide.com
// Licensed under the MIT (MIT-LICENSE.txt)
//------------------------------------------------------------------------------
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.IO;

namespace DNAide.Drawing
{

	public static partial class BitmapAide
	{

		/// <summary>
		/// Returns a bitmap from a file.
		/// Improves on new Bitmap(filename) as this does not lock the
		/// original file which Bitmap(filename) may.
		/// http://support.microsoft.com/?id=814675
		/// </summary>
		/// <param name="path"></param>
		/// <returns></returns>
		public static Bitmap Load(string path)
		{
			FileStream stream = File.OpenRead(path);
			Bitmap loadedBitmap = new Bitmap(stream);

			Bitmap returnBitmap = BitmapAide.CopyBitmap(loadedBitmap);
		
			loadedBitmap.Dispose();
			loadedBitmap = null;

			stream.Close();
			return returnBitmap;
		}

	
	}
}